<template>
    <div>
        <el-container>
            <el-header>
                <div class="headerDiv">
                    <div class="logoAndTitle">
                        <img alt="Vue logo" src="../assets/jiyun.png" style="width: 100px; height: 47px" />
                        <h3>积云教育</h3>
                    </div>
                    <!--头像-->
                    <div class="imageDiv">
                        <img alt="Vue logo" src="../assets/test2.png" style="width: 40px; height: 40px" />
                        <h5>
                            <span>欢迎你：{{user.name}} </span>
                            <el-button type="text" @click="logout">退出</el-button>
                        </h5>
                    </div>
                </div>
            </el-header>
            <el-container>
                <el-aside style="width: 200px;">
                    <!--先开启路由模式-->
                    <el-menu router
                             default-active="/count"
                             class="el-menu-vertical-demo">
                        <el-submenu index="1">
                            <template slot="title">
                                <i class="el-icon-location"></i>
                                <span>数据管理</span>
                            </template>
                            <el-menu-item index="/count">
                                <i class="el-icon-user-solid"></i>
                                <span slot="title">数据统计</span>
                            </el-menu-item>

                            <el-menu-item index="/rr">
                                <i class="el-icon-user-solid"></i>
                                <span slot="title">调寝管理</span>
                            </el-menu-item>

                            <el-menu-item index="/bx">
                                <i class="el-icon-user-solid"></i>
                                <span slot="title">报修管理</span>
                            </el-menu-item>

                            <el-menu-item index="1-2">
                                <i class="el-icon-menu"></i>
                                <span slot="title">班级管理</span>
                            </el-menu-item>
                            <el-menu-item index="1-3">
                                <i class="el-icon-menu"></i>
                                <span slot="title">教师管理</span>
                            </el-menu-item>
                        </el-submenu>
                        <el-menu-item index="2">
                            <i class="el-icon-menu"></i>
                            <span slot="title">导航二</span>
                        </el-menu-item>
                        <el-menu-item index="3" disabled>
                            <i class="el-icon-document"></i>
                            <span slot="title">导航三</span>
                        </el-menu-item>
                        <el-menu-item index="4">
                            <i class="el-icon-setting"></i>
                            <span slot="title">导航四</span>
                        </el-menu-item>
                    </el-menu>
                </el-aside>
                <el-main>
                    <!--锚点-->
                    <router-view/>
                </el-main>
            </el-container>
        </el-container>




    </div>
</template>

<script>
    export default {
        name: "index",
        data(){
            return {

                user:{

                }

            }
        },
        methods:{
            logout(){
                localStorage.removeItem("sushe_user");
                this.$router.push("/")
            },

        },
        created(){
            let user = localStorage.getItem("sushe_user")
            if(!user){
                this.$message.error("没有登录呢，即将跳转");
                setTimeout(()=>{
                    this.$router.push("/")
                },2000)
            }else{
                this.user = JSON.parse(user);
            }
        }
    }
</script>

<style scoped>
    .el-header{
        background-color: #47e6ff;
    }
    .el-aside{
        height: 550px;
    }
    .el-main{
    }
    .headerDiv{
        display: flex;
        justify-content: space-between;
    }
    .logoAndTitle{
        display: flex;
        align-items: center;
    }
    .imageDiv{
        display: flex;
        align-items: center;
    }
    .logoAndTitle h3{
        margin-left: 10px;
    }
    .imageDiv h5{
        margin-left: 5px;
    }
    .imageDiv img{
        border-radius: 40px;
    }
    .el-menu{

        height: 550px;
    }
</style>
